﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SMS.Statistics
{
    public partial class TransactionsStat : System.Web.UI.Page
    {
        SMS.Business.Stocks.StocksBusiness SB;

        protected void Page_Load(object sender, EventArgs e)
        {
            
            SB = new Business.Stocks.StocksBusiness();
            drpStocks.Items.Add(new ListItem() { Text = "الكل", Value = "-1" });
            drpStocks.DataSource = SB.Search(new DAL.Providers.StockSearchCriteria() { Name = string.Empty, type = null });
            drpStocks.DataTextField = "Name";
            drpStocks.DataValueField = "ID";
            drpStocks.DataBind();
        }
        protected void drpStocks_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            SMS.Business.StatisticsBusiness Stat = new Business.StatisticsBusiness();
            SMS.DAL.Providers.StatObjects.StatData x= Stat.GetData(int.Parse(drpStocks.SelectedValue),DateTime.Parse(txtFrom.Text),DateTime.Parse(txtTo.Text));
            lblOrderBuyNum.Text = x.OrderBuyNum.ToString();
            lblOrderSellNum.Text = x.OrderSellNum.ToString();
            grsShortage.DataSource = x.ItemsNeeded;
            grsShortage.DataBind();
            
        }
    }
}